# -*- coding:utf-8 -*-

from wtforms import Form, StringField, PasswordField, SubmitField, SelectField
from wtforms.validators import DataRequired, EqualTo, Length

render_kw = {}


class LoginForm(Form):
    username = StringField(
        label='用户名',
        validators=[DataRequired()],
        render_kw={'placeholder': '用户名', 'class': 'form-control'}
    )
    password = PasswordField(
        label='密码',
        validators=[DataRequired(), Length(6, 16, '密码长度必须在6-16之间')],
        render_kw={'placeholder': '密码', 'class': 'form-control'}

    )
    submit = SubmitField(
        label='提交',
        render_kw={'class': 'btn btn-success pull-right'}
    )


class RegisterForm(LoginForm):
    repassword = PasswordField(
        label='确认密码',
        validators=[DataRequired(), EqualTo('password', '两次密码不一致')],
        render_kw={'placeholder': '再次输入密码', 'class': 'form-control'}

    )

class StudentForm(Form):
    name = StringField(
        label='姓名',
        validators=[DataRequired()],
        render_kw={'placeholder': '用户名', 'class': 'form-control'}
    )
    gender = SelectField(
        label='性别',
        validators=[DataRequired()],
        choices=['男', '女'],
        render_kw={'placeholder': '用户名', 'class': 'form-control'}
    )
    class_name = StringField(
        label='班级',
        render_kw={'placeholder': '班级', 'class': 'form-control'}
    )
    submit = SubmitField(
        label='提交',
        render_kw={'class': 'btn btn-success pull-right'}
    )

class StudentSearchForm(Form):
    name = StringField(
        label='姓名',
        validators=[DataRequired()],
        render_kw={'placeholder': '用户名', 'class': 'form-control', 'style': 'display: inline-block; width: calc(100% - 75px);'}
    )
    submit = SubmitField(
        label='搜索',
        render_kw={'class': 'btn btn-success', 'style': 'width: 50px;'}
    )
